#!/usr/bin/python2.7

from cVector2 import Vector2 as V2
from math import sqrt 
#moguce je koristiti import math , pri cemu bi 
#se ucitale sve funkcije iz math biblioteke
#sto nije dobro jer usporava izvrsenje skripte

class Segment:
  def __init__(self, arg1, arg2, arg3=0, arg4=0):
    if isinstance(arg1, V2): self.point1 = arg1
    if isinstance(arg2, V2): self.point2 = arg2
    
    if isinstance(arg1, int) or isinstance(arg1, float):
      self.point1 = V2(arg1, arg2)
      self.point2 = V2(arg3, arg4)

  def length(self):
    return sqrt((self.point1.x - self.point2.x)**2 + (self.point1.y - self.point2.y)**2)

  def __str__(self):
    return "(%.2f,%.2f):(%.2f,%.2f)" % (self.point1.x, self.point1.y, self.point2.x, self.point2.y)

if __name__ == "__main__":
  seg1 = Segment(V2(1,1),V2(4,4))
  seg2 = Segment(V2(0,0),V2(4,0))
  seg3 = Segment(0,0,-10,0)

  print(seg1)
  print(seg2)
  print(seg3)

  print(seg1.length())
  print(seg2.length())
  print(seg3.length())